/*
 * ModelCC, distributed under ModelCC Shared Software License, www.modelcc.org
 */

package org.modelcc.language.syntax.builder;

import java.io.Serializable;

import org.modelcc.language.metamodel.LanguageModel;
import org.modelcc.language.syntax.ObjectWrapper;
import org.modelcc.language.syntax.ParserMetadata;
import org.modelcc.language.syntax.Symbol;
import org.modelcc.language.syntax.SymbolBuilder;

/**
 * Token symbol builder
 * 
 * @author Luis Quesada (lquesada@modelcc.org) & Fernando Berzal (fberzal@modelcc.org)
 */
public final class TokenSymbolBuilder extends SymbolBuilder implements Serializable 
{
	/**
	 * Constructor
	 * @param model Language model
	 */
	public TokenSymbolBuilder (LanguageModel model)
	{
		super(model);
	}
	
    /**
     * Builds a token symbol.
     * @param t symbol to be built.
     * @param data the parser metadata.
     * @return true if the symbol is valid, false if not
     */
    @Override
	public boolean build(Symbol t, ParserMetadata data) 
    {
        data.getMap().put(t.getUserData(),new ObjectWrapper(t.getUserData(),getModel(),t.getInputSymbol().getString()));
        return true;
    }
}
